package cn.iocoder.yudao.module.biz.dal.mysql.risk.riskMethodDetail;

import java.io.Serializable;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.module.biz.controller.admin.risk.riskMethodDetail.vo.BizRiskMethodDetailExportReqVO;
import cn.iocoder.yudao.module.biz.controller.admin.risk.riskMethodDetail.vo.BizRiskMethodDetailPageReqVO;
import cn.iocoder.yudao.module.biz.dal.dataobject.risk.riskMethodDetail.BizRiskMethodDetailDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 评级方法从 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BizRiskMethodDetailMapper extends BaseMapperX<BizRiskMethodDetailDO> {

    default PageResult<BizRiskMethodDetailDO> selectPage(BizRiskMethodDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BizRiskMethodDetailDO>()
                .eqIfPresent(BizRiskMethodDetailDO::getMethodCount, reqVO.getMethodCount())
                .eqIfPresent(BizRiskMethodDetailDO::getMethodDetail, reqVO.getMethodDetail())
                .eqIfPresent(BizRiskMethodDetailDO::getMethodContent, reqVO.getMethodContent())
                .eqIfPresent(BizRiskMethodDetailDO::getType, reqVO.getType())
                .eqIfPresent(BizRiskMethodDetailDO::getMethodNameId, reqVO.getMethodNameId())
                .orderByDesc(BizRiskMethodDetailDO::getId));
    }

    default List<BizRiskMethodDetailDO> selectList(BizRiskMethodDetailExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BizRiskMethodDetailDO>()
                .eqIfPresent(BizRiskMethodDetailDO::getMethodCount, reqVO.getMethodCount())
                .eqIfPresent(BizRiskMethodDetailDO::getMethodDetail, reqVO.getMethodDetail())
                .eqIfPresent(BizRiskMethodDetailDO::getMethodContent, reqVO.getMethodContent())
                .eqIfPresent(BizRiskMethodDetailDO::getType, reqVO.getType())
                .eqIfPresent(BizRiskMethodDetailDO::getMethodNameId, reqVO.getMethodNameId())
                .orderByDesc(BizRiskMethodDetailDO::getId));
    }
    default List<BizRiskMethodDetailDO> getRiskMethodDetailType(String methodNameId){
        QueryWrapperX queryWrapper = new QueryWrapperX();
        queryWrapper.select("DISTINCT type").orderByAsc("ind");
        queryWrapper.eqIfPresent("method_name_id",methodNameId);
        return selectList(queryWrapper);
    }

    @Override
    default List<BizRiskMethodDetailDO> selectBatchIds(Collection<? extends Serializable> ids){
        QueryWrapperX queryWrapper = new QueryWrapperX();
        queryWrapper.in("id",ids).orderByAsc("ind");
        return selectList(queryWrapper);
    }
}
